<template>
  <div class="mod-config">
    <basic-container>
      <navigationZDRW :sign="{ a: false, b: true, c: false }"></navigationZDRW>
      <div class="boxsty zhiBiao">
        <div :height="searchheight">
          <span
            style="float: right; margin-top: -30px; cursor: pointer"
            @click="searchchangeadvanced"
            >{{ searchadvanced ? "查询条件收起" : "查询条件展开" }}
            <i
              :class="
                searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'
              "
            />
          </span>
          <div v-show="searchadvanced">
            <el-form
              :inline="true"
              :model="dataForm"
              @keyup.enter.native="getDataList()"
              class="form-inline"
            >
              <el-form-item label="任务书名称">
                <el-input
                  v-model="dataForm.workAssignName"
                  placeholder="任务书名称"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人">
                <el-input
                  v-model="dataForm.ryName"
                  placeholder="考核人"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人岗位">
                <el-input
                  v-model="dataForm.userZw"
                  placeholder="被考核人岗位"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人职级">
                <el-input
                  style="width: 150px"
                  v-model="dataForm.userZj"
                  placeholder="被考核人职级"
                  :clearable="true"
                ></el-input>
              </el-form-item>
              <el-form-item>
                <el-button
                  icon="el-icon-search"
                  type="primary"
                  class="marginLeft"
                  @click="getDataList()"
                  >检索
                </el-button>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <div class="avue-crud">
          <div
            class="flex"
            style="
              justify-content: space-between;
              border-top: 1px solid #b0bde2;
              padding-top: 10px;
            "
          >
            <div></div>
            <div class="pull-right">
              <el-button
                type="primary"
                @click="commitAll(1)"
                plain
                v-loading.fullscreen.lock="fullscreenLoading"
                >批量提交</el-button
              >
              <el-button
                type="primary"
                 @click="commitAll(0)"
                plain
                v-loading.fullscreen.lock="fullscreenLoading"
                >结束</el-button
              >
            </div>
          </div>
          <el-table
            style="width: 100%; margin-top: 10px"
            :data="dataList"
            border
            ref="table"
            v-loading="dataListLoading"
          >
            <el-table-column
              type="selection"
              width="55"
              header-align="center"
              align="center"
            ></el-table-column>
            <el-table-column
              type="index"
              width="80"
              header-align="center"
              align="center"
              label="序号"
            ></el-table-column>
            <el-table-column
              prop="workAssignName"
              header-align="center"
              align="center"
              min-width="200"
              show-overflow-tooltip
              label="任务书名称"
            >
              <template slot-scope="scope">
                <span
                  @click="checkDetails(scope.row)"
                  style="color: #0e258c; cursor: pointer"
                  >{{ scope.row.workAssignName }}</span
                >
              </template>
            </el-table-column>
            <el-table-column
              prop="userName"
              header-align="center"
              align="center"
              min-width="120"
              show-overflow-tooltip
              label="被考核人编号"
            >
            </el-table-column>
            <el-table-column
              prop="ryName"
              header-align="center"
              align="center"
              min-width="120"
              show-overflow-tooltip
              label="被考核人姓名"
            >
            </el-table-column>
            <el-table-column
              prop="userDeptName"
              header-align="center"
              align="center"
              min-width="120"
              show-overflow-tooltip
              label="被考核人单位"
            >
            </el-table-column>
            <el-table-column
              prop="userZj"
              header-align="center"
              align="center"
              label="被考核人职级"
              min-width="180"
              show-overflow-tooltip
            >
            </el-table-column>
            <el-table-column
              prop="userZw"
              header-align="center"
              align="center"
              min-width="180"
              show-overflow-tooltip
              label="被考核人岗位"
            >
            </el-table-column>
            <el-table-column
              prop="indiNumbers"
              header-align="center"
              align="center"
              min-width="100"
              show-overflow-tooltip
              label="指标数量"
            >
            </el-table-column>
            <el-table-column
              prop="stateExplain"
              header-align="center"
              align="center"
              min-width="120"
              label="任务书状态"
            >
            </el-table-column>
          </el-table>
        </div>
        <div class="avue-crud__pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            :total="totalPage"
            background
            layout="total, sizes, prev, pager, next, jumper"
          >
          </el-pagination>
        </div>
      </div>
      <fqcommon ref="fqcommon" @fqcommonchild="getDataList"></fqcommon>
    </basic-container>
  </div>
</template>

<script>
import { getPageForqtjc, qtjcsubmitAll } from "@/api/hetongrenwu/book/bookQtjc";
import fqcommon from "../fqcommon";
import { mapGetters } from "vuex";

export default {
  components: {
    fqcommon,
  },
  created() {
    this.getDataList();
  },
  data() {
    return {
      dataForm: {},
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      searchadvanced: true,
      searchheight: "0",
      tableShow: true,
      showType: 1,
      fullscreenLoading: false,
    };
  },
  computed: {
    ...mapGetters(["permissions"]),
  },
  methods: {
    commitAll(num) {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.warning("请勾选所提交的数据");
        return;
      } else {
          var params={
              type:num,
              rows:data
          }
        qtjcsubmitAll(params).then((res) => {
          this.$message({
            type: "success",
            message: res.data.data,
          });
          this.fullscreenLoading = false;
          this.getDataList();
        });
      }
    },
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = "auto";
      }
    },
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;
      getPageForqtjc(
        Object.assign(
          {
            current: this.pageIndex,
            size: this.pageSize,
          },
          this.dataForm
        )
      ).then((response) => {
        this.dataList = response.data.data.records;
        this.totalPage = response.data.data.total;
        this.dataListLoading = false;
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    //编辑查看
    checkDetails(row) {
      this.$refs.fqcommon.init(row,'qtjc');
    },
  },
};
</script>
